﻿using Newtonsoft.Json;
using OSSUtility.BLL;
using OSSUtility.Models;
using Ozone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ozone.BLL
{
    public class SetParamBLL
    {
        static public SetConfigParam get()
        {
            SetConfigParam model = null;
            ConfigParamBLL bll = new ConfigParamBLL();
            ConfigParam configParam = bll.get("SetConfigParam");
            if (configParam != null)
            {
                model = JsonConvert.DeserializeObject<SetConfigParam>(configParam.FContent);
            }
            else
            {
                //model = new SetConfigParam();
                //configParam = new ConfigParam("SetConfigParam", JsonConvert.SerializeObject(model), Guid.NewGuid().ToString());
                //bll.Save(configParam);
            }

            return model;
        }

        static public void set(SetConfigParam model)
        {
            ConfigParamBLL bll = new ConfigParamBLL();
            ConfigParam configParam = bll.get("SetConfigParam");
            if (configParam == null)
            {
                configParam = new ConfigParam("SetConfigParam", JsonConvert.SerializeObject(model));
            }

            configParam.FContent = JsonConvert.SerializeObject(model);
            bll.Save(configParam);
        }



    }
}
